import pymongo as pm
import os

client = pm.MongoClient('localhost', 27017)

tbl = client.tvts['train_log_mnist_multi_clf_by_numpynet_mlp_softmax_ok']

cursor = tbl.find({'save_path': {'$ne': None}})

for row in cursor:
    id = row['_id']
    save_path = row['save_path']
    if os.path.isabs(save_path):
        continue
    save_dir = row['save_dir']
    path = os.path.join(save_dir, save_path)
    ret = tbl.find_one_and_update({'_id': id}, {
        '$set': {'save_path': path}
    })
    print(ret)
